package yja.gzw.app.activity

import android.util.Log
import android.widget.Toast
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import yja.gzw.app.R
import yja.gzw.app.adapter.ZanheshoucangAdapter
import yja.gzw.app.adapter.ZhuanquAdapter
import yja.gzw.app.base.BaseActivity
import yja.gzw.app.databinding.ActivityZanheshoucangBinding
import yja.gzw.app.model.UserData
import yja.gzw.app.viewmodel.Mainviewmodel

class ZanheshoucangActiviry :BaseActivity<Mainviewmodel, ActivityZanheshoucangBinding>(R.layout.activity_zanheshoucang){

    private lateinit var fabiada: ZanheshoucangAdapter
    override fun initView() {
        binding.fanhui.setOnClickListener {
            finish()

        }
            viewmodel.onzanheshoucangwang(UserData.token, mapOf("pagesize" to "10","page" to "1"))
    }

    override fun dataObservese() {
        viewmodel.onzanheshoucang.observe(this, Observer {
            if(it.code==1){

                binding.review.layoutManager=
                    LinearLayoutManager(this)
                fabiada= ZanheshoucangAdapter(this,it.data)
                binding.review.adapter= fabiada


            }else{

                Toast.makeText(this,it.msg, Toast.LENGTH_SHORT).show()
            }


        })


    }
}